-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Capture shorthand_field_initializer and modules in Rust highlights
#35842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture shorthand_field_initializer and modules in Rust highlights
#35842
Conversation
Currently shorthand field initializers are not captured the same way as the full initializers leading to awkward and mismatching highlighting. In addition, captures the `!` as part of a macro invocation.
1bedb1d to
8896e87
Compare
shorthand_field_initializer in rust highlightsshorthand_field_initializer and modules in rust highlights
shorthand_field_initializer and modules in rust highlightsshorthand_field_initializer and modules in Rust highlights
This should rather be done in a separate PR as its a more sizable edit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is an interesting change. I do have some reservations, primarily that these changes seem to be personal preferences, however, the impact would be universal. I'm not sure there's a way around that besides allowing customization of *.scm files by users. Additionally, if we do merge this, I definitely feel that we should remove the changes to imports. In my view, inconsistent highlighting is worse than consistent less semantic highlighting.
If you would please remove the import highlighting changes, and update the before and after screenshots to include examples of all changes I would be happy to review again
|
Thank you for the review @probably-neb! I agree that it would be beneficial for users to be able to specify their own capture groups in I think a good solution for the time being could be to allow users to have more granular highlighting options (while keeping the defaults sane). Currently, if something is not captured there is no way to replace the default highlighting, if something is, then there is the choice of either using the provided colored (i.e. from a color scheme) or overriding it themselves. In any case, I've gone ahead and removed the use statement captures, and I also wrote up a quick Rust demo program to show off all the adjustments this PR makes. Hopefully this makes it clear of all the changes this time. |
…ed-industries#35842) Currently shorthand field initializers are not captured the same way as the full initializers, leading to awkward and mismatching highlighting. This PR addresses this fact, in addition to capturing new highlights: - Tags the `!` as part of a macro invocation. - Tags the identifier part of a lifetime as `@lifetime`. - Tag module definitions as a new capture group, `@module`. - Shorthand initializers are now properly tagged as `@property`. Here's what the current version of Zed looks like: <img width="596" height="683" alt="image" src="https://github.com/user-attachments/assets/c9e52d8e-03dc-426b-8545-4fe872b803e0" /> With the new highlighting applied: <img width="596" height="683" alt="image" src="https://github.com/user-attachments/assets/b7bd9391-9910-456b-8198-6871174d0f4f" /> Release Notes: - Improved highlighting of Rust files, including new highlight groups for modules and shorthand initializers.
…hlights (#35842)" (#36880) This PR reverts #35842, as it broke the syntax highlighting for `crate`: ### Before Revert <img width="367" height="70" alt="Screenshot 2025-08-25 at 11 29 50 AM" src="https://github.com/user-attachments/assets/ce9b8b59-4e89-43ed-84c7-95c0156b9168" /> ### After Revert <img width="353" height="69" alt="Screenshot 2025-08-25 at 11 32 17 AM" src="https://github.com/user-attachments/assets/b6df5a21-64db-4abf-aa76-f085236da0c4" /> This reverts commit 896a35f. Release Notes: - Reverted #35842.
…ed-industries#35842) Currently shorthand field initializers are not captured the same way as the full initializers, leading to awkward and mismatching highlighting. This PR addresses this fact, in addition to capturing new highlights: - Tags the `!` as part of a macro invocation. - Tags the identifier part of a lifetime as `@lifetime`. - Tag module definitions as a new capture group, `@module`. - Shorthand initializers are now properly tagged as `@property`. Here's what the current version of Zed looks like: <img width="596" height="683" alt="image" src="https://github.com/user-attachments/assets/c9e52d8e-03dc-426b-8545-4fe872b803e0" /> With the new highlighting applied: <img width="596" height="683" alt="image" src="https://github.com/user-attachments/assets/b7bd9391-9910-456b-8198-6871174d0f4f" /> Release Notes: - Improved highlighting of Rust files, including new highlight groups for modules and shorthand initializers.
…hlights (zed-industries#35842)" (zed-industries#36880) This PR reverts zed-industries#35842, as it broke the syntax highlighting for `crate`: ### Before Revert <img width="367" height="70" alt="Screenshot 2025-08-25 at 11 29 50 AM" src="https://github.com/user-attachments/assets/ce9b8b59-4e89-43ed-84c7-95c0156b9168" /> ### After Revert <img width="353" height="69" alt="Screenshot 2025-08-25 at 11 32 17 AM" src="https://github.com/user-attachments/assets/b6df5a21-64db-4abf-aa76-f085236da0c4" /> This reverts commit 896a35f. Release Notes: - Reverted zed-industries#35842.
…ed-industries#35842) Currently shorthand field initializers are not captured the same way as the full initializers, leading to awkward and mismatching highlighting. This PR addresses this fact, in addition to capturing new highlights: - Tags the `!` as part of a macro invocation. - Tags the identifier part of a lifetime as `@lifetime`. - Tag module definitions as a new capture group, `@module`. - Shorthand initializers are now properly tagged as `@property`. Here's what the current version of Zed looks like: <img width="596" height="683" alt="image" src="https://github.com/user-attachments/assets/c9e52d8e-03dc-426b-8545-4fe872b803e0" /> With the new highlighting applied: <img width="596" height="683" alt="image" src="https://github.com/user-attachments/assets/b7bd9391-9910-456b-8198-6871174d0f4f" /> Release Notes: - Improved highlighting of Rust files, including new highlight groups for modules and shorthand initializers.
…hlights (zed-industries#35842)" (zed-industries#36880) This PR reverts zed-industries#35842, as it broke the syntax highlighting for `crate`: ### Before Revert <img width="367" height="70" alt="Screenshot 2025-08-25 at 11 29 50 AM" src="https://github.com/user-attachments/assets/ce9b8b59-4e89-43ed-84c7-95c0156b9168" /> ### After Revert <img width="353" height="69" alt="Screenshot 2025-08-25 at 11 32 17 AM" src="https://github.com/user-attachments/assets/b6df5a21-64db-4abf-aa76-f085236da0c4" /> This reverts commit 896a35f. Release Notes: - Reverted zed-industries#35842.
Currently shorthand field initializers are not captured the same way as the full initializers, leading to awkward and mismatching highlighting. This PR addresses this fact, in addition to capturing new highlights:
!as part of a macro invocation.@lifetime.@module.@property.Here's what the current version of Zed looks like:
With the new highlighting applied:
Release Notes: